﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Configuration;
using System.Text;

namespace WxShop.Controllers
{
    public class HomeController : Controller
    {
        private string url = ConfigurationManager.AppSettings["ApiUrl"];

        public ActionResult Index()
        {
            //todo:调用api 返回首页信息
            //var json1 = Tools.GetWebRequest(url + "/api/ProductsApi?productTypeID=1&topNum=4", "", "json", Encoding.UTF8);
            //var json2 = Tools.GetWebRequest(url + "/api/ProductsApi?productTypeID=2&topNum=4", "", "json", Encoding.UTF8);
            //var json3 = Tools.GetWebRequest(url + "/api/ProductsApi?productTypeID=3&topNum=4", "", "json", Encoding.UTF8);
            //ViewData["json1"]  = json1;
            //ViewData["json2"] = json2;
            //ViewData["json3"] = json3;
            //var res = new JsonResult();
            //res.Data = json1;
            ViewData["url"] = url;
            return View();
        }

        public ActionResult Details(string id)
        {
            //var model = Tools.GetWebRequest(url + "/api/ProductsApi/" + id, "", "json", Encoding.UTF8);
            ViewData["url"] = url;
            ViewData["pcode"] = id;
            return View();
        }

        public ActionResult Cart()
        {
            return View();
        }
        public ActionResult LogOut()
        {
            return View();
        }


        //public ActionResult About()
        //{
        //    ViewBag.Message = "Your application description page.";

        //    return View();
        //}

        //public ActionResult Contact()
        //{
        //    ViewBag.Message = "Your contact page.";

        //    return View();
        //}
    }
}